using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;

namespace CD2WebAudio3UI.Forms
{
    public partial class frmAbout : Form
    {
        public frmAbout()
        {
            InitializeComponent();
        }

        private void frmAbout_Load(object sender, EventArgs e)
        {
            try
            {
                // set the icon
                pictureBox1.Image = Icon.ToBitmap();

                // set the product information
                string txt = "CD to Web Audio 3 \r\n";
                string copyright = string.Empty;
                string company = string.Empty;
                Assembly me = Assembly.GetExecutingAssembly();
                txt += "Revision:  " + me.GetName().Version.ToString() + "\r\n";
                object[] attribs = me.GetCustomAttributes(true);

                for (int i = 0; i < attribs.Length; i++)
                {
                    Attribute attr = (Attribute)attribs[i];
                    if (attr.GetType().Name.CompareTo("AssemblyCopyrightAttribute") == 0)
                    {
                        AssemblyCopyrightAttribute cr = (AssemblyCopyrightAttribute)attr;
                        copyright = cr.Copyright;
                    }
                    else if (attr.GetType().Name.CompareTo("AssemblyCompanyAttribute") == 0)
                    {
                        AssemblyCompanyAttribute co = (AssemblyCompanyAttribute)attr;
                        company = co.Company;
                    }
                }

                txt += copyright + "\r\n";

                label1.Text = txt;

                textBox1.Text = info_Text();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error loading form.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }



        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        
        private string info_Text()
        {
            string returnVal = "This software is licensed under GPL 3.  The full text of the license agreement can be found in LICENSE.txt.\r\n\r\n";

            returnVal += "Acknowledgements:\r\n\r\n";

            returnVal += "LAME, Copyright 2001 www.mp3dev.org.\r\n";
            returnVal += CD2WebAudio3Lib.mp3_creator.Get_Lame_Version();
            returnVal += "\r\nRipper, Copyright 2002-2003 Idael Cardoso.\r\n";
            returnVal += "LAME Interop, Copyright 2002-2003 Idael Cardoso.\r\n\r\n";
            returnVal += "C# ID3 Library, Copyright 2002-2008 Hugo Ramayor.\r\n";
            returnVal += "     http://sourceforge.net/projects/csid3lib\r\n\r\n";

            returnVal += "Source available at:\r\n";
            returnVal += "http://cd2webaudio.codeplex.com/\r\n";

            return returnVal;

        }

    }
}